package icangyu.base.utils;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ExecutorPool {

     static ThreadPoolExecutor executor ;

     public static ThreadPoolExecutor getInstance() {
         if(executor == null) {
             synchronized (ExecutorPool.class) {
                 if(executor == null) {
                     executor = new ThreadPoolExecutor(
                             Runtime.getRuntime().availableProcessors() * 2,
                             Runtime.getRuntime().availableProcessors() * 2,
                             60L,
                             TimeUnit.SECONDS,
                             new LinkedBlockingQueue<Runnable>());
                 }
             }
         }
         return executor;
     }

}
